home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 116 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: clamage@Eng.sun.com (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: order of evaluation
  5. Date: 22 Jan 1996 17:22:42 GMT
  6. Organization: Sun Microsystems Inc.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4e0gpg$4dp@engnews1.Eng.Sun.COM>
  9. References: <4e0dr0$aul@rznews.rrze.uni-erlangen.de>
  10. Reply-To: clamage@Eng.sun.com
  11. NNTP-Posting-Host: taumet.eng.sun.com
  12. Content-Type: text
  13. X-Nntp-Posting-Host: taumet.eng.sun.com
  14. Content-Length: 1513
  15. X-Lines: 39
  16. Originator: clamage@taumet
  17.  
  18. In article aul@rznews.rrze.uni-erlangen.de, anhaeupl@late.e-technik.uni-erlangen.de (Bernd Anhaeupl) writes:
  19. >In various places the DWP specifies, that the order of evaluation of
  20. >some expressions is unspecified. 
  21.  
  22. >1.) Does this mean, that for example in the following function call
  23. >
  24. >    f(a(...),b(....),c(....));
  25. >
  26. >    a(...), b(...), c(...) may even be evaluated in parallel in a
  27. >    multitasking environment? 
  28.  
  29. No. Section 1.8 says function calls may not be interleaved. In your
  30. example, "a", "b", and "c" may be called in any order, but whichever
  31. one is called first must complete before the second one is called.
  32. (The C++ language definition does not address parallelizing of program
  33. execution, but we can talk about interleaving parts of expressions.)
  34.  
  35.  
  36. >2.) Is it legal for a compiler to reorder the evaluation of
  37. >    the operator new and the constructor calls of some new expressions.
  38. >    For example, is it legal for a compiler to evaluate
  39.  
  40. >    f(new a(new b()))             or    f2(new a, new b)   (see also question 1)
  41. >                       in the following order:
  42.  
  43. >    tmp1=a::new(sizeof(a));             tmp1=a::new(sizeof(a))
  44. >    tmp2=b::new(sizeof(b));             tmp2=b::new(sizeof(b))
  45. >    tmp2.b();                           tmp1.a()
  46. >    tmp1.a(tmp2);                       tmp2.b() 
  47. >    f(tmp1);                            f2(tmp1,tmp2);
  48.  
  49. I believe the reordering is allowed, because I don't think there is
  50. any sequence point that prevents it. 
  51.  
  52. ---
  53. Steve Clamage, stephen.clamage@eng.sun.com
  54.  
  55.  
  56.  
  57. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  58.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  59.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  60.  
  61.